﻿Public Class WfAltDesp1
    Inherits System.Web.UI.Page
    Dim objDesp As New Despachante
  

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("AdmLogado") Is Nothing Then
            Response.Redirect("/Screens/WF1.aspx")
        End If
        PopulaTextBox()

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim objDespDao As New DespachateDAO

        objDesp.StatusDesp = dropStatus.SelectedValue.ToString
        Try
            objDespDao.AtualizarStatus(objDesp)
            lbmsg.ForeColor = Drawing.Color.Blue
            lbmsg.Text = "Cadastro Atualizado com Sucesso !"
        Catch ex As Exception
            lbmsg.ForeColor = Drawing.Color.Red
            lbmsg.Text = " Erro ao Atualizar Cadastro !"
        End Try

    End Sub

    Private Sub Page_PreRender(sender As Object, e As System.EventArgs) Handles Me.PreRender
        If Session("AdmLogado") Is Nothing Then
            Response.Redirect("/Screens/WF1.aspx")
        End If
    End Sub

    Public Sub PopulaTextBox()
        Dim objDespDao As New DespachateDAO
        Dim objDespParam As New Despachante
        objDesp = objDespDao.SelectDespfantasia(Request.QueryString("NomeDesp"))

        tbnome.Text = objDesp.FantasiaDesp
        tbemail.Text = objDesp.EmailDesp
        tbtel.Text = objDesp.TelDesp
        tbend.Text = objDesp.EndDesp
        tbcpf.Text = objDesp.CpfCnpjDesp
        tbsatus.Text = objDesp.StatusDesp
        If tbsatus.Text = "Bloquedo" Then
            tbsatus.ForeColor = Drawing.Color.Red
        ElseIf tbsatus.Text = "Inativo" Then
            tbsatus.ForeColor = Drawing.Color.Blue
        ElseIf tbsatus.Text = "Ativo" Then
            tbsatus.ForeColor = Drawing.Color.Green
        End If

    End Sub
End Class